package nc.ui.arap.buttonstat;

import nc.ui.arap.engine.AbstractRuntime;
import nc.ui.arap.engine.ExtButtonObject;
import nc.ui.arap.engine.IActionRuntime;
import nc.ui.arap.engine.IButtonStatus;
import nc.ui.arap.global.DjTempletHelper;
import nc.ui.ep.dj.ArapBillWorkPageConst;
import nc.vo.ep.dj.DJZBHeaderVO;
import nc.vo.ep.dj.DJZBVO;
import nc.vo.ep.dj.DJZBVOConsts;

public class DjAdjustStatListener implements IButtonStatus {

	public void updateButtonStatus(ExtButtonObject bo, IActionRuntime runtime) {

		// TODO Auto-generated method stub
		if(null != StatListenerHelper.getDjPanel(runtime)){
			int panelprop = StatListenerHelper.getDjPanel(runtime).getPanelProp();
			if(panelprop == 1 || panelprop == 2 || panelprop == 3 || panelprop == 4){
				bo.setVisible(false);
				return ;
			}
		}
		if (!(runtime instanceof AbstractRuntime))
			return;
		AbstractRuntime runt = (AbstractRuntime) runtime;
		bo.setEnabled(false);
		if(runt.getCurrWorkPage()==ArapBillWorkPageConst.CARDPAGE){
			DJZBVO djvo = runt.getDjDataBuffer().getCurrentDJZBVO();
			if(djvo != null && DjTempletHelper.isCardInQuery(runt)){
				DJZBHeaderVO head = (DJZBHeaderVO) djvo.getParentVO();
				if(head != null && head.getSxbz() != null && head.getSxbz() == DJZBVOConsts.m_intSXBZ_VALID){
					bo.setEnabled(true);
					bo.setVisible(true);
				}
			}

		}
	}

}
